package com.example.his.api.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.example.his.api.common.R;
import com.example.his.api.mis.service.PermissionService;
import org.apache.poi.ss.formula.functions.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;


@RestController
@RequestMapping ( "/mis/permission" )
public class PermissionController {

  @Resource
  private PermissionService permissionService;

  /**
   * 查询所有权限列表
   * 需要 ROOT 或 ROLE:INSERT 权限才能访问
   *
   * @return 包含权限列表的响应结果
   */
  @GetMapping("/searchAllPermission")
  @SaCheckPermission(value = {"ROOT", "ROLE:INSERT"}, mode = SaMode.OR)
  public R searchAllPermission() {
    // 调用服务层方法查询所有权限信息
    ArrayList<HashMap> list = permissionService.searchAllPermission();
    // 将查询结果封装到R对象中返回
    return R.ok().put("list", list);
  }


}
